rm(list=ls())

##############################################################################
# APPENDIX B4 TABLE 1
##############################################################################

# load packages
#library(texreg)

# load data 
load("data/candidate_GCI_RB.RData")

##############
# RUN MODELS #
##############

LM1_RB <- lm(votes ~ ranking + factor(region), data = RBcandidate_GCI)
#summary(LM1_RB)

LM2_RB <- lm(votes ~ ranking + factor(region) + log_gdp_percap, data = RBcandidate_GCI)
#summary(LM2_RB)

LM3_RB <- lm(votes ~ ranking + factor(region) + log_gdp_percap + 
               log_pop + idealpoint_US + idealpoint_RU + nato_bin + eu_bin + g77_bin + oic_bin, data = RBcandidate_GCI)
#summary(LM3_RB)


################
# CREATE TABLE #
################

appendB3_tab3 <- screenreg(list(LM1_RB,LM3_RB), custom.coef.map = list("votes" = "votes", 
                                                                       "ranking" = "ranking", 
                                                                       "log_gdp_percap" = "log GDP percap", 
                                                                       "log_pop" = "log population", 
                                                                       "idealpoint_US" = "UN voting (distance from US)", 
                                                                       "idealpoint_RU" = "UN voting (distance from Russia)",
                                                                       "nato_bin" = "NATO", 
                                                                       "eu_bin" = "EU", 
                                                                       "g77_bin" = "G77", 
                                                                       "oic_bin" = "OIC"),
                           omit.coef = c("region", "elect_year", "Constant"), 
                           custom.gof.rows = list("Region FE" = c("YES", "YES"), 
                                                  "Controls" = c("NO","YES")), digits = 3, 
                           stars = c(0.001, 0.01, 0.05, 0.1)) 

print(appendB3_tab3)

# script complete message 
print("appendB3_tab3 complete")